<%@ page language="java" import="java.util.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List producerList = (List)request.getAttribute("producerlist");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>

<script src="<%=basePath %>app/javascripts/jquery-1.5.1.js"></script>
<script src="<%=basePath %>app/javascripts/layout.js"></script>
<script src="<%=basePath %>common/javascript/common.js"></script>
<script src='<%=basePath%>dwr/engine.js'></script>
<script src='<%=basePath%>dwr/util.js'></script> 
<script src='<%=basePath%>dwr/interface/datamanagerdwr.js'></script> 
<script src='<%=basePath%>common/uploadify/jquery-1.5.1.min.js'></script> 
<script src='<%=basePath%>common/uploadify/swfobject.js'></script>
<script src='<%=basePath%>common/uploadify/jquery.uploadify.v2.1.4.min.js'></script>
<link rel="stylesheet" type="text/css" href="<%=basePath %>app/css/layout.css" />
<link rel="stylesheet" type="text/css" href="<%=basePath%>common/uploadify/uploadify.css" />

<style>.tac{text-align:center}</style>
<script>
$(document).ready(function() {
  $('#file_upload').uploadify({
    'uploader'  : '<%=basePath%>common/uploadify/uploadify.swf',
    'script'    : '<%=basePath %>data/importdata.do',
    'cancelImg' : '<%=basePath%>common/uploadify/cancel.png',
    'folder'    : '<%=basePath%>upload',
    'queueID'   : 'fileQueue',
    'fileDataName':'importfile',
    'auto'      : false,
    'muti'     : false,
    'multi': false, 
	'buttonImg' : '<%=basePath%>common/uploadify/selectfile.gif',  
	'fileExt'        : '*.xls',   
    'fileDesc'       : 'excel文件(*.xls)', 
    onComplete: function (event, queueID, fileObj, response, data) {
   		alert("上传成功");  
   		window.parent.datalist.frameElement.src = "<%=basePath%>data/dataList.do?state=0"; 	
   　},
   	onError: function(event, queueID, fileObj) {      
		alert("上传失败");
    }
    
  });
});

 function distributeFirst(){ 
 	var producer = distributeform1.dataProducer.value;
 	var c = parent.frames("datalist").document.all.checkbox;
 	var result = "" ;
 	 for(var i=0;i<c.length;i++)
	 {
	     if(c[i].checked){
	     	result = result + c[i].value + ",";
	     }
	 }
	if(result.length>1){
		datamanagerdwr.distributeFirst(producer,result,callback4distributeFirst);
	}
 	 
 }
 
function callback4distributeFirst(message){
    if("0" == message){
 	    alert("没有可分配的案件");  
 	}else{
 	   alert("分配成功!，本次分配" + message + "个案件");
 	   window.parent.datalist.frameElement.src = "<%=basePath%>data/dataList.do"; 
 	} 
 }
 //分配方式二
 function distributeSecond(){
 	var producer = distributeform2.dataProducer.value;
 	var num = distributeform2.casenumber.value;
 	if(isNull(num)){
 		alert("分配案件个数不能为空");
 	}else {
 		datamanagerdwr.distributeSecond(producer,num,callback4distributeSecond); 
 	}
 }
  function callback4distributeSecond(message){
    if("0" == message){
 	    alert("分配成功");  
 	    window.parent.datalist.frameElement.src = "<%=basePath%>data/dataList.do"; 
 	}else{
 	   alert("分配失败!，只有" + message + "个案件可以分配");
 	} 
 }
 </script>
</head>
<body>
<div class="cont">
    <table border="0" cellspacing="0" cellpadding="0" class="block">
      <tr>
        <th colspan="4">数据导入</th>
      </tr>
      <tr>
      	<td>
      		<div id="fileQueue" align="center"> 
              <input id="file_upload" name="file_upload" type="file" />	&nbsp;&nbsp;
              <input type="button" onclick="jQuery('#file_upload').uploadifyUpload()" value="开始上传" class="but_2"/> 
              <input type="button" onclick="jQuery('#file_upload').uploadifyClearQueue()" value="取消上传" class="but_2"/> 
              </div>
      	
      	</td>
      </tr>
    </table>
</div>

</body>
</html>
<script>

</script>
